<template>
  <div ref="wrap" class="parentStyle">
    <el-table v-loading="loading" :data="dealTrackList" border :max-height="tableHeight">
      <el-table-column :label="$t('序号')" type="index" align="center" show-overflow-tooltip>
        <template slot-scope="scope">
          {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column :label="$t('修改人')" align="center" prop="userId" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row.createBy.nickName }}</span>
        </template>
      </el-table-column>
      <el-table-column :label="$t('修改时间')" align="center" prop="happenTime" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime,'{y}-{m}-{d} {h}:{i}') }}</span>
        </template>
      </el-table-column>
      <!--      <el-table-column :label="$t('评价类型')" align="center" prop="itemType" show-overflow-tooltip :formatter="itemTypeFormat" />-->
      <!--      <el-table-column v-if="useProcess" :label="$t('审批状态')" align="center" width="120">-->
      <!--        <template slot-scope="scope">-->
      <!--          <ProcessStatus :status="scope.row.actStatus" :act-id="scope.row.actId" />-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <el-table-column :label="$t('操作')" fixed="right" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            v-hasPermi="['afterInvest:evaluation:remove']"
            size="small"
            type="text"
            @click="getDetail(scope.row)"
          >{{ $t('详情') }}</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改投后评价对话框 -->
    <el-dialog :title="$t('版本对比')" :visible.sync="formOpen" :close-on-click-modal="false" :lock-scroll="false" custom-class="dialogForm" append-to-body>
      <evaluation-change-form ref="evaluationForm" :is-deal="false" :deal-id="$route.query.id" />
    </el-dialog>
  </div>
</template>

<script>
import { getChangeList } from '@/api/afterInvest/evaluation/dealAfterInvestEvaluation'
import EvaluationChangeForm from '@/views/deal/afterInvest/evaluationChangeForm.vue'

export default {
  components: { EvaluationChangeForm },
  data() {
    return {
      // 遮罩层
      loading: false,
      // 总条数
      total: 0,
      // 发生时间 参数
      happenTimes: undefined,
      // 投后评价表格数据
      dealTrackList: [],
      // 弹出层标题
      title: '投后评价',
      // 是否显示弹出层
      formOpen: false,
      // 评价 字典evaluation_type
      itemTypeOptions: [],
      // 查询参数
      queryParams: {
        personChargeName: undefined,
        dealId: undefined,
        startDate: undefined,
        endDate: undefined,
        itemType: undefined,
        trackMode: undefined,
        otherPeople: undefined,
        details: undefined,
        pageNum: 1,
        pageSize: 10
      },
      // 表单参数
      form: {},
      tableHeight: 200,
      // 表单校验
      rules: {
      },
      previewTit: ''
    }
  },
  created() {
    this.getList()
  },
  mounted() {
    this.setTableHeight()
  },
  methods: {
    setTableHeight() {
      const $refs = this.$refs
      const totalHeight = $refs.wrap.offsetHeight
      const minTableHeight = 50
      this.$nextTick(() => {
        this.tableHeight = totalHeight - minTableHeight
      })
    },
    getDetail(row) {
      this.formOpen = true
      this.$nextTick(() => {
        this.$refs.evaluationForm.init(row)
      })
    },
    init(data) {
      console.log(data)
      this.loading = true
      if (data && data.sourceId) {
        this.queryParams.dataId = data.sourceId
        this.getList()
      } else {
        this.loading = false
      }
    },
    /** 查询投后评价列表 */
    getList() {
      this.loading = true
      getChangeList(this.queryParams).then(response => {
        this.dealTrackList = response.rows
        this.total = response.total
        this.loading = false
      })
    }
  }
}
</script>

<style scoped>

</style>
